package com.mzj.saas.sdk.wxsdk;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class WxConfig extends WXPayConfig{
	
	/** 加载证书 */
	private byte[] certData;

	private String appId;
	private String mchId;
	private String key;
	
	/**
	 * 配置证书
	 * @throws Exception
	 */
    public WxConfig() throws Exception {
//        String certPath = "/path/to/apiclient_cert.p12";
//        File file = new File(certPath);
//        InputStream certStream = new FileInputStream(file);
//        this.certData = new byte[(int) file.length()];
//        certStream.read(this.certData);
//        certStream.close();
    }
    
    public WxConfig(String appid,String mchId,String key) {
    	this.appId = appid;
    	this.mchId = mchId;
    	this.key = key;
    }
    
	@Override
	public String getAppID() {
		// TODO Auto-generated method stub
		return appId;
	}

	@Override
	public String getMchID() {
		// TODO Auto-generated method stub
		return mchId;
	}

	@Override
	public String getKey() {
		// TODO Auto-generated method stub
		return key;
	}

	@Override
	public InputStream getCertStream() {
		// TODO Auto-generated method stub
		ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
	}

	@Override
	public IWXPayDomain getWXPayDomain() {
		// TODO Auto-generated method stub
		IWXPayDomain iwxPayDomain = new IWXPayDomain() {
            @Override
            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }
            @Override
            public DomainInfo getDomain(WXPayConfig config) {
                return new IWXPayDomain.DomainInfo("api.mch.weixin.qq.com", true);
            }
        };
        return iwxPayDomain;
	}
	
	
	
}
